<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use kartik\datetime\DateTimePicker;
use  yii\widgets\ActiveForm;
use backend\modules\orders\models\OrderInfo;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\pooai\models\search\ZpooaiPagesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '订单列表');
$this->params['breadcrumbs'][] = $this->title;
$this->registerCssFile('@web/css/admin.css');
?>
<?php $form = ActiveForm::begin([
    'action' =>['/orders/orderinfo/index'],
    'method' => 'post'
]);?>
<div class="zpooai-pages-index">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns' => [
            [
                'class' => '\kartik\grid\CheckboxColumn',
            ],
            [
                'class' => 'yii\grid\SerialColumn',
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
            ],

            [
                'label'=>'订单编号',
                'format'=>'raw',
                'attribute' => 'order_sn',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return $m->order_sn;
                }
            ],
            [
                'label'=>'收货人信息',
                'format'=>'raw',
                'attribute' => 'consignee',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return "收货人:$m->consignee<br /><br />收货地址:$m->country_name  $m->province_name $m->city_name $m->district_name<br />$m->address";
                }
            ],
            [
                'label'=>'订单正常总价',
                'format'=>'raw',
                'attribute' => 'order_amount',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return $m->order_amount;
                }
            ],
            [
                'label'=>'订单需支付总价',
                'format'=>'raw',
                'attribute' => 'goods_amount',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return $m->goods_amount;
                }
            ],
            [
                'label'=>'订单已支付总价',
                'format'=>'raw',
                'attribute' => 'money_paid',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return $m->money_paid;
                }
            ],
            [
                'label'=>'订单状态',
                'format'=>'raw',
                'attribute' => 'order_status',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return OrderInfo::orderStatusAlias($m->order_status);
                },
                'filter' => OrderInfo::orderStatusAlias("all"),
            ],
            //时间组件
            [
                'attribute' => 'add_time',
//                 'headerOptions' => ['width' => '150px'],
//                'class'=>'kartik\grid\EditableColumn',
//                'editableOptions'=>[
//                    'inputType'=>\kartik\editable\Editable::INPUT_DATETIME,
//                    'asPopover' => false,
//                    'contentOptions' => ['style'=>'width:250px'],
//                ],
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'filter' => DateTimePicker::widget([
                    'language' => 'zh-CN',
                    'model' => $searchModel,
                    'type' => DateTimePicker::TYPE_COMPONENT_APPEND,
                    'attribute' => 'created_at',
                    'options' => ['class' => 'input-sm mymiddle'],
                    'pluginOptions' => [
                        'format' => 'yyyy-mm-dd hh:ii:ss',
                        'autoclose' => true,
                        'minView' => 'month',
                    ]]),
                'value'=>function($model){
                    return  date('Y-m-d H:i:s',$model->created_at);   //主要通过此种方式实现
                },
            ],



            [
                'class' => 'kartik\grid\ActionColumn',
                'headerOptions' => ['class' => 'kartik-sheet-style'],
            ],
        ],


        'export' => false,
        'responsive' => true,
        'panel' => [
            'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> ' .Yii::t('Wxuser','订单列表'). '</h3>',
            'type' => 'success',
//            'before' => Html::a('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('Wxuser','创建商品'), ['create'], ['class' => 'btn btn-success']),
            'footer' => false,
            'after' => false
        ],
        'toolbar' => [
            [
                'content' =>
                    Html::dropDownList('act', '',
                        [
                            '' => Yii::t('Wxuser','选择操作') ,
                            'delete' =>  Yii::t('Wxuser','删除') ,

                        ],
                        ['class' => 'btn btn-default', 'style' => 'margin-right:10px']) . Html::submitButton( Yii::t('Wxuser','保存'), ['class' => 'btn btn-success']),
                'options' => ['class' => 'btn-group-sm'],
                '{export}',
                '{toggleData}'
            ],
            'toggleDataContainer' => ['class' => 'btn-group-sm'],
            'exportContainer' => ['class' => 'btn-group-sm']
        ]
    ]); ?>
</div>
<?php ActiveForm::end(); ?>
